<script type="text/javascript">
	
function TreeNode(x) {
    this.val = x;
    this.left = null;
    this.right = null;
}

function createSearchTree(root, data) {
	// debugger
	let p = root;

	if(p.val <= data) {
		if(!p.left) {
			p.left = new TreeNode(data);
		} else {
			createSearchTree(p.left, data);
		}
	} else {
		if(!p.right) {
			p.right = new TreeNode(data);
		} else {
			createSearchTree(p.right, data);
		}
	}
}

let arr = [4,2,5,,3,6];
let root = new TreeNode(arr[0]);
for(let i = 1; i < arr.length; i++) {
	createSearchTree(root, arr[i])
}
console.log(root)


</script>